<?php
/**
 * Created by PhpStorm.
 * User: linfang
 * Date: 2016/8/10
 * Time: 21:13
 */
//包含一个文件上传类中的上传类
include "FileUpload/FileUpload.php";
session_start();
header("content-type:text/html;charset=utf-8");
include "Mysql/MySqlClass.php";
$mySQL = new Ycf\Lession\MySqlClass\MySqlClass('jinling_company', 'root', '123456');
$up    = new FileUpload;
//设置属性(上传的位置， 大小， 类型， 名是是否要随机生成)
$up->set("path", "./images/");
$up->set("maxsize", 2000000);
$up->set("allowtype", array("gif", "png", "jpg", "jpeg"));
$up->set("israndname", true);
$up->upload("pic");
$pictureName     = $up->getFileName();
$productDir      = "images/" . $pictureName;
$productName     = $_POST['productName'];
$productDescripe = $_POST['productDescripe'];
$productType=$_POST['productTypeId'];
$productType =$_POST['productType'];//获得产品类型
$productDate     = date('y-m-d h:i:s', time()); //当前的编辑时间
$admin           = $mySQL->select("admin", $where = array('adminName' => $_SESSION['userName']));
$productInsert   = array('adminId' => $admin['id'], 'productName' => $productName, 'productPictureDir' => $productDir,
    'productDescript'                  => $productDescripe, 'productTypeId'  =>$productType,'productDate'  => $productDate);
$MySQL->insert("product", $productInsert);
header("Location:productList.php");

